<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Rag Hu
 * Created Time: 2019/8/19 16:36
 * Modified Time: 2019/8/19 16:36
 * Version: 2.0
 */

namespace App\Modules\MemberCard\Repositores;


use App\Lib\Utilities;
use App\Models\Backup;
use Flower\Core\Repository\Eloquent\BaseRepository;

class BackupRepository extends BaseRepository
{
    public function model()
    {
        return Backup::class;
    }

    //返回名字
    public function backupName($store_id)
    {
        //获取之前备份次数
        $count = $this->model->where('store_id', $store_id)->get()->count();

        $count = Utilities::numberToChinese($count + 1);

        return '第' . $count . '次备份';
    }

    //新增
    public function createBackup($store_id, $user_id, $count, $name)
    {
        $data = [
            'store_id' => $store_id,
            'user_id' => $user_id,
            'count' => $count,
            'name' => $name
        ];
        return $this->create($data);
    }
}